// var serverUrl = 'http://39.99.243.57:8080'
// var sendSms = serverUrl + "/web/v1/account/sendSms"
// var register = serverUrl + "/web/v1/account/register"
// var loginByPwd = serverUrl + "/web/v1/account/loginByPwd"
// var projectList = serverUrl + "/web/v1/job/project/list"
// var memberProjectList = serverUrl + "/web/v1/member/job/project/list"//项目外包列表
// var memberProjectAdd = serverUrl + "/web/v1/member/job/project/add"//发布外包项目
// var memberProjectEdit = serverUrl + "/web/v1/member/job/project/edit"
// var jobMemberList = serverUrl + "/web/v1/member/job/post/list"//职位列表
// var jobAdd = serverUrl + "/web/v1/member/job/post/add"//添加职位
// var jobDetails = serverUrl + "/web/v1/member/job/post/edit"
// var jobList = serverUrl + "/web/v1/job/post/list"//职位招聘列表
import './jquery.js'
import Vue, { del } from 'vue';
import axios from 'axios';
import Qs from 'qs'
import request from '@/utils/request'

import layer from '../../node_modules/layui-layer/layer';
import API from './API.js';
const common = {
	 requestGet(url,data,callback) {
		// var index = layer.load(0, {shade: false});
		// let getUrl = API.serverUrl + url
		// var result = ''
		// $.ajax({
		// 	type: "GET",
		// 	url:getUrl,
		// 	dataType: "json",
		// 	headers: {
		// 	    'token': window.localStorage.getItem('token'),
		// 	},
		// 	data:data,
		// 	async:false,
		// 	success: function(res) {
		// 		layer.close(index);
		// 		callback(res)
		// 	},
		// 	error: function(res) {
		// 		layer.close(index);
		// 		if(res.responseJSON.code == 500){
		// 			localStorage.removeItem('userInfo')
		// 			localStorage.removeItem('userId')
		// 			localStorage.removeItem('token')
		// 			layer.msg(res.responseJSON.msg);
					
		// 			callback(res)
		// 		} else if (res.responseJSON.code == 401){
		// 			layer.msg('请登录!');
		// 		} else {
		// 			layer.msg('请求异常!');
		// 		}
		// 	},
		// });
		// return result

		return request({
            url: url,
            method: 'get',
            params:data,
			callbackFn:callback
        })
	},
	
	 requestPost(url,data,callback) {
		// var index = layer.load(0, {shade: false});
		// let getUrl = API.serverUrl + url
		// var result = '';

		// let headers={
		// 	'token': window.localStorage.getItem('token')
		// }
		// if(url=='/web/v1/member/article/add2'||url=='/web/v1/member/article/edit2'){
		// 	headers['Content-Type']='application/json;charset=utf-8';
		// 	data=JSON.stringify(data);
		// }
		// $.ajax({
		// 	type: "POST",
		// 	url:getUrl,
		// 	dataType: "json",
		// 	headers:headers,
		// 	data:data,
		// 	async:false,
		// 	success: function(res) {
		// 		layer.close(index);
		// 		if(res.code == 0){
		// 			callback(res)
		// 		}else{
		// 			callback(res)
		// 		}
		// 	},
		// 	error: function(res) {
		// 		layer.close(index);
		// 		if(res.responseJSON.code == 500){
		// 			localStorage.removeItem('userInfo')
		// 			localStorage.removeItem('userId')
		// 			localStorage.removeItem('token')
		// 			layer.msg(res.responseJSON.msg);
					
		// 			callback(res)
		// 		} else if (res.responseJSON.code == 401){
		// 			layer.msg('请登录!');
		// 		} else {
		// 			layer.msg('请求异常!');
		// 		}
		// 	},
		// });
		// return result
		if(data.params)delete data.params;
		let requestObj={
            url: url,
            method: 'post',
            data:data,
			callbackFn:callback
        }
		if(url=='/web/v1/member/article/add2'||url=='/web/v1/member/article/edit2'){
			requestObj.iscommon=true
			requestObj.headers={}
			requestObj.headers['Content-Type']='application/json;charset=utf-8';
			requestObj.data=JSON.stringify(requestObj.data);
		}
		return request(requestObj)
	},
	debounce(func, delay){
		let timer;
		return function (...args) {
			if (timer) {
			clearTimeout(timer)
			}
			timer = setTimeout(() => {
			func.apply(this, args)
			}, delay)
		}
	}
}
export default common
// module.exports = common
